package leetcode.剑指offer.前40;

import org.junit.Test;

import java.util.HashSet;

/**
 * @author ：zsy
 * @date ：Created 2021/7/17 22:57
 * @description：https://leetcode-cn.com/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/
 */
public class 剑指_03_数组中重复的数字 {
    @Test
    public void test() {
        Solution solution = new Solution();
    }

    class Solution {
        public int findRepeatNumber(int[] nums) {
            HashSet<Integer> set = new HashSet<>();
            for (int num : nums) {
                if (!set.add(num)) {
                    return num;
                }
            }
            return -1;
        }
    }

}
